<?php
class Log {
	const ERROR_LEVEL = 0;
	const WARNING_LEVEL = 1;
	const INFO_LEVEL = 2;
	const DEBUG_LEVEL = 3;
	
	static public $threshhold = self::WARNING_LEVEL;
	
	static private function logMsg($level, $msg) {
		static $names = array( 
			self::ERROR_LEVEL => 'ERROR',
			self::WARNING_LEVEL => 'WARNING',
			self::INFO_LEVEL => 'INFO',
			self::DEBUG_LEVEL => 'DEBUG'
		);
			
		printf("%s - [%s] : %s\n", $names[$level], strftime('%d/%m/%Y %H:%M:%S'), $msg);
	}
	
	static public function error($msg) {
		if( self::ERROR_LEVEL > self::$threshhold ) return;
		$args = array_slice(func_get_args(),1);
		self::logMsg(self::ERROR_LEVEL, vsprintf($msg, $args));	
	}
	static public function warn($msg) {
		if( self::WARNING_LEVEL > self::$threshhold ) return;
		$args = array_slice(func_get_args(),1);
		self::logMsg(self::WARNING_LEVEL, vsprintf($msg, $args));	
	}
	static public function info($msg) {
		if( self::INFO_LEVEL > self::$threshhold ) return;
		$args = array_slice(func_get_args(),1);
		self::logMsg(self::INFO_LEVEL, vsprintf($msg, $args));	
	}
	static public function debug($msg) {
		if( self::DEBUG_LEVEL > self::$threshhold ) return;
		$args = array_slice(func_get_args(),1);
		self::logMsg(self::DEBUG_LEVEL, vsprintf($msg, $args));	
	}
}